package pojo;


import tuple.data.DataKind;
import tuple.entity.MyEntity;

import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;

public class MyTuple {
    public Set<MyEntity> entity;
    //    public String verb = "Collect";
    public Set<DataKind> data;
    public Set<String> stringMarks;
    //    public final String[] CONDITIONS = {"No Condition", "Condition"};

    public MyTuple(MyEntity entity, DataKind data) {
        this.entity = new HashSet<>();
        this.data = new HashSet<>();
        this.stringMarks = new HashSet<>();
        this.entity.add(entity);
        this.data.add(data);
    }

    public MyTuple(MyEntity entity, DataKind data, Set<String> stringMarks) {
        this.entity = new HashSet<>();
        this.data = new HashSet<>();
        this.entity.add(entity);
        this.data.add(data);
        this.stringMarks = stringMarks;
    }

    public MyTuple(Set<MyEntity> entity, Set<DataKind> data) {
        this.entity = entity;
        this.data = data;
    }

    public MyTuple(Set<MyEntity> entity, Set<DataKind> data, Set<String> stringMarks) {
        this.entity = entity;
        this.data = data;
        this.stringMarks = stringMarks;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        MyTuple myTuple = (MyTuple) o;
        return Objects.equals(entity, myTuple.entity)
//                & Objects.equals(verb, myTuple.verb)
                && Objects.equals(data, myTuple.data)
                && Objects.equals(stringMarks, myTuple.stringMarks);
    }

    @Override
    public int hashCode() {
        return Objects.hash(entity, data, stringMarks);
    }


    @Override
    public String toString() {
        String entityString = entity.stream()
                .map(MyEntity::getName)
                .collect(Collectors.joining(", ", "(", ")"));
        String dataString = data.stream()
                .map(DataKind::getName)
                .collect(Collectors.joining(", ", "(", ")"));
        String marksString = stringMarks.stream()
                .collect(Collectors.joining(", ", "(", ")"));
        if (marksString.length() > 255)
            marksString = marksString.substring(0, 255) + "...";
        return String.format("<%s, Collect, %s, %s>", entityString, dataString, marksString);
    }
}
